package com.oig.sys.auth.dto;


import com.oig.common.validator.GroupAdd;
import com.oig.common.validator.GroupChange;
import com.oig.common.validator.GroupEdit;
import com.oig.common.validator.EnumValue;
import com.oig.sys.auth.constants.AuthEnums;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@Data
@Schema(description = "菜单显示列")
public class ResourceColumnDto {

    @Schema(description = "主键id")
    private Integer id;

    @Schema(description = "用户个性化菜单id")
    private Integer userColumnId;

    @Schema(description = "编码")
    private String code;

    @Schema(description = "菜单id")
    private Integer resourceId;

    @Schema(description = "列名称", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误，列名称不能为空", groups={GroupAdd.class, GroupEdit.class})
    private String columnName;

    @Schema(description = "列实体属性代码--可以不用了")
    //@NotEmpty(message = "参数错误，实体属性代码不能为空", groups={GroupAdd.class, GroupEdit.class})
    private String columnProperty;

    @Schema(description = "列所属表--可以不用了")
    //@NotEmpty(message = "参数错误，所属表不能为空")
    private String columnTableName;

    @Schema(description = "列所属表代码--可以不用了")
    //@NotEmpty(message = "参数错误，所属表代码不能为空")
    private String columnTable;

    @Schema(description = "数据库列代码--可以不用了")
    //@NotEmpty(message = "参数错误，数据库列代码不能为空")
    private String columnCol;

    @Schema(description = "列排序序号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "参数错误，列排序序号不能为空", groups={GroupChange.class})
    private Integer listSort;

    @Schema(description = "列枚举json")
    private String enumValueJson;

    @Schema(description = "列是否是主键列,默认第一行是主键")
    private Boolean isPrimaryKey=false;
    @Schema(description = "列是否固定--暂时不考虑，看是否能支持,默认为0-不固定")
    private Boolean isOrderFlag = false;
    @Schema(description = "列是否允许个性化  默认 true可以")
    private Boolean isChangeFlag = true;
    @Schema(description = "列是否显示  默认 1可以")
    private Boolean isShowFlag = true;

    @Schema(description = "列显示对齐方式   0-左对齐 1-居中 2-右对齐 默认0", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误，列显示对齐方式不能为空", groups={GroupChange.class})
    @EnumValue(message = "对齐方式值不对", enumClass=AuthEnums.AlignEnum.class, enumValidMethod ="validCode", groups={GroupChange.class})
    private String showAlign;

    @Schema(description = "列显示宽度 默认 无", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误，列显示宽度不能为空", groups={GroupChange.class})
    private String showWidth;
    @Schema(description = "列显示样式json")
    private String showClassJson;

    @Schema(description = "列别名", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "列别名不能为空", groups={GroupAdd.class, GroupEdit.class, GroupChange.class})
    private String columnField;

    @Schema(description = "列值类型: 0-数值（浮点数+整数）1-整数  2-字符串 3-日期 4-日期时间 5-时间 6-枚举 当枚举时enum_value_json有值", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "列值类型不能为空", groups={GroupAdd.class, GroupEdit.class})
    @EnumValue(message = "列值类型值不对", enumClass=AuthEnums.ValueType.class, enumValidMethod ="validCode", groups={GroupAdd.class, GroupEdit.class})
    private String columnValueType ;

    @Schema(description = "列是否支持查询: 当用通用查询的时候,默认否 0-否 1-是")
    private String queryFlag ;

    @Schema(description = "列支持查询时，默认是否显示 0-否 1-是（收起）")
    private String queryShowFlag;

    @Schema(description = "列查询组件类型: 0-文本 1-between  2-枚举下拉框 3-查询下拉框 4-弹框查询  当=1时 取enum_value_json值 2~3默认支持多选")
//    @EnumValue(message = "列查询组件类型值不对", enumClass=AuthEnums.QueryType.class, enumValidMethod ="validCode", groups={GroupAdd.class, GroupEdit.class})
    private String queryType ;

    @Schema(description = "查询列依赖接口 当queryType=3/4 需要")
    private String queryTypeApi ;

    @Schema(description = "列查询组件显示顺序号")
    private Integer querySort ;

}
